<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .active {
            color: red;
        }
    </style>
  
</head>

<body>
    <div id="app1">
        <!-- 所有写vue的东西必须在#app这个dom里 -->
        <!-- {{message}} -->
        <div v-text="message"></div>
        <div v-html="message"></div>
        <input type="checkbox" @change="fn1">
        <button @click="fn">点击我修改flag</button>
        <div v-show="flag">
            <!-- v-if的值为true渲染，为false不渲染 -->
              <!-- v-show控制元素的隐藏和显示，为真显示，为假不显示-->
            <li v-for="(item, index) in list" :key="index">{{item}}</li>
        </div>






        --------------------


        <span v-for="(item, ind) in arrs" :key="ind" @click="changeIndex(ind)" :class="[ind==index?'active':'']">{{item.tit}}</span>
        <div>{{arrs[index].con}}</div>


      
    </div>
    <script src="https://cdn.jsdelivr.net/npm/vue@2"></script>
    <script>
        var app = new Vue({
            el: '#app1',
            // data是存放变量的地方
            data: {
                message: '<span>Hello Vue!</span>',
                list:[1,2,3,4,5],
                flag:true,
                arrs:[
                    {
                        tit:"标题1",
                        con:"内容1"
                    },
                    {
                        tit:"标题2",
                        con:"内容2"
                    },
                    {
                        tit:"标题3",
                        con:"内容3"
                    }
                ],
                index:0
            },
            // methods是放方法的，里面用到data里的变量前面要加this
            methods: {
                fn() {
                    alert(1)
                    this.flag  = !this.flag
                },
                fn1(){
                    console.log(11111)
                },
                changeIndex(index){
                    this.index = index
                }
            },
        })
    </script>
</body>

</html>